import {LGXEnums}  from "../../common/sysenum.js";

import utilfuncs from "../../common/tools/utilfuncs.js";
var funcs = utilfuncs.UtilFuncs;
var ModifySpePolygonSvc = {}

ModifySpePolygonSvc.drag2Modify = function (destGraph, newTransform) {
    let cnt = destGraph.centerPt;
    let PtInCtrlLocal = newTransform.destInverseMtx.MultT({ x: cnt.x, y: cnt.y, z: 0 });//求相对于控制图形局部坐标系的局部坐标
    let newWolrdPt = newTransform.newDestMtx.MultT(PtInCtrlLocal);
    let scale = newTransform.newDestMtx.GetS();
    destGraph.centerPt.x = newWolrdPt.x;
    destGraph.centerPt.y = newWolrdPt.y;
    let oldW = destGraph.width;
    let oldH = destGraph.height;
    destGraph.width = oldW * scale.x;
    destGraph.height = oldH * scale.y;

    let pos = destGraph.getPos();
    for (let i = 0; i < pos.posList.length; i++) {
        let pt = pos.posList[i];
        let PtInCtrlLocal = newTransform.destInverseMtx.MultT({ x: pt.x, y: pt.y, z: 0 });//求相对于控制图形局部坐标系的局部坐标
        let newWolrdPt = newTransform.newDestMtx.MultT(PtInCtrlLocal);
        pt.x = newWolrdPt.x;
        pt.y = newWolrdPt.y;
    }
}

export default { ModifySpePolygonSvc }